
<template>
  <Row class="video-realtime-row" style="min-height:80vh;">
    <!-- <Col :span="19" class="realtime-left-container" style="padding:0 16px 30px;box-sizing:border-box;">
    <div class="w1 h1" id="hotvideo-real-time"></div>
    </Col>
    <Col :span="5" class="realtime-right-container distribute-right-controller">
    <Row>
      <Form :label-width="80">
        <FormItem label="appKey：">
          <Input size="small" v-model="appKey" />
        </FormItem>
        <FormItem label="secret：">
          <Input size="small" v-model="secret" />
        </FormItem>
        <FormItem>
          <Button size="small" @click="loadInitData">加载数据</Button>
        </FormItem>
      </Form>
    </Row>
    </Col> -->
    <iframe style="width:100%;height:800px;" id="iframe" ref="iframe" frameborder="0" scrolling="no" :src="src">
    </iframe>
  </Row>
</template>
<script>
import './index.scss'
import { haiKangWithBrowserTye, haiKangPluginExist } from '@/utils/check-browser'
import { getVideoParams } from '@/api'
// require('@/utils/webVideoCtrl')

/**
 * 
 * http://127.0.0.1:4320/plugin/execute/vssworkstation

{"userName":"admin",
"ISMS_8700_CASTGC":"TGT-66-PVBphchIp4z2da2r5TZthp0G9S3UvXr791KVWrLCl6ZT6FM7cQ-cas",
"cmsIP":"47.92.248.136",
"cmsPort":8090,"skinType":"red",
"moduleIndex":1}

post
 */

export default {
  props: {
    type: {
      type: String,
      default: '1'
    }
  },
  mounted() {
    const { params } = this.$route
    this.id = params.id
    this.initData()
  },

  data: () => ({
    id: '',
    baseInfo: {},
    src: ''
  }),
  methods: {
    initData() {
      const params = {
        id: this.id
      }
      getVideoParams(params).then(res => {
        this.baseInfo = res.data.base
        const { deviceNo, heatDirectStream, videoDirectStream } = this.baseInfo
        if (this.type === 1) {
          if (deviceNo.startsWith('dl')) {
            this.src = heatDirectStream
          } else if (deviceNo.startsWith('hk')) {
            if (haiKangWithBrowserTye()) {
              haiKangPluginExist().then(flag => {
                if (flag) {
                  this.src =
                    'http://47.92.248.136:8090/openapi/demo/mpv/mpv.html'
                }
              })
            }
          }
        } else {
          if (deviceNo.startsWith('dl')) {
            this.src = videoDirectStream
          } else if (deviceNo.startsWith('hk')) {
            if (haiKangWithBrowserTye()) {
              haiKangPluginExist().then(flag => {
                if (flag) {
                  this.src =
                    'http://47.92.248.136:8090/openapi/demo/mpv/mpv.html'
                }
              })
            }
          }
        }
      })
    }
  }
}
</script>

// clsid:863E7B58-A280-40A5-8394-CE33F4E7B654"
// PLAYBACKOCX.PlaybackOcxCtrl.1